Imports System 
Imports System.Text 
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.Common
Imports System.Collections
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Configuration 
Imports System.Xml 
Imports System.Xml.Serialization
Imports SubSonic 
Imports SubSonic.Utilities
Namespace Data
    ''' <summary>
    ''' Controller class for WebSettings
    ''' </summary>
		<System.ComponentModel.DataObject()> Public Partial Class WebSettingsController
    
        ' Preload our schema..
        Dim thisSchemaLoad As WebSettings = New WebSettings()
        Private strUserName As String = String.Empty
        Protected ReadOnly Property UserName() As String
            Get
				If strUserName.Length = 0 Then
		        
    				If Not System.Web.HttpContext.Current Is Nothing Then
						strUserName = System.Web.HttpContext.Current.User.Identity.Name
					Else
		        		strUserName = System.Threading.Thread.CurrentPrincipal.Identity.Name
					End If
					Return strUserName
				End If
				Return strUserName
			End Get
        End Property
        <DataObjectMethod(DataObjectMethodType.Select, True)> Public Function FetchAll() As WebSettingsCollection
        
            Dim coll As WebSettingsCollection = New WebSettingsCollection()
            Dim qry As Query = New Query(WebSettings.Schema)
            coll.LoadAndCloseReader(qry.ExecuteReader())
            Return coll
            
        End Function
        <DataObjectMethod(DataObjectMethodType.Select, True)> Public Function FetchByID(ByVal Id As Object) As WebSettingsCollection 
        
            Dim coll As WebSettingsCollection = New WebSettingsCollection().Where("ID", Id).Load()
            Return coll
        
        End Function
        
        <DataObjectMethod(DataObjectMethodType.Select, True)> Public Function FetchByQuery(ByVal qry As SubSonic.Query) As WebSettingsCollection 
        
            Dim coll As WebSettingsCollection = New WebSettingsCollection()
            coll.LoadAndCloseReader(qry.ExecuteReader())
            Return coll
        
        End Function
        <DataObjectMethod(DataObjectMethodType.Delete, True)> Public Function Delete(ByVal Id As Object) as Boolean
        
            Return (WebSettings.Delete(Id) = 1)
        
        End Function
        <DataObjectMethod(DataObjectMethodType.Delete, False)> Public Function Destroy(ByVal Id As Object) as Boolean
        
            Return (WebSettings.Destroy(Id) = 1)
        
        End Function
        
    	
	    ''' <summary>
	    ''' Inserts a record, can be used with the Object Data Source
	    ''' </summary>
        <DataObjectMethod(DataObjectMethodType.Insert, True)> Public Sub Insert(ByVal Name As String,ByVal Slogan As String,ByVal Copyright As String,ByVal Address As String,ByVal SiteURL As String,ByVal MailServer As String,ByVal MailUsername As String,ByVal MailPassword As String,ByVal EmailVerification As Boolean,ByVal AdminVerification As Boolean,ByVal PageSize As Integer,ByVal ReportCMS As Boolean,ByVal Webmaster As String,ByVal IsHighestWinner As Boolean,ByVal ModerationLevel As Integer,ByVal CurrentSeason As Integer)
	   
		    Dim item As WebSettings = New WebSettings()
		    
            item.Name = Name
            
            item.Slogan = Slogan
            
            item.Copyright = Copyright
            
            item.Address = Address
            
            item.SiteURL = SiteURL
            
            item.MailServer = MailServer
            
            item.MailUsername = MailUsername
            
            item.MailPassword = MailPassword
            
            item.EmailVerification = EmailVerification
            
            item.AdminVerification = AdminVerification
            
            item.PageSize = PageSize
            
            item.ReportCMS = ReportCMS
            
            item.Webmaster = Webmaster
            
            item.IsHighestWinner = IsHighestWinner
            
            item.ModerationLevel = ModerationLevel
            
            item.CurrentSeason = CurrentSeason
            
	    
		    item.Save(UserName)
	   
	   End Sub
    	
	    ''' <summary>
	    ''' Updates a record, can be used with the Object Data Source
	    ''' </summary>
        <DataObjectMethod(DataObjectMethodType.Update, True)> Public Sub Update(ByVal Id As Integer,ByVal Name As String,ByVal Slogan As String,ByVal Copyright As String,ByVal Address As String,ByVal SiteURL As String,ByVal MailServer As String,ByVal MailUsername As String,ByVal MailPassword As String,ByVal EmailVerification As Boolean,ByVal AdminVerification As Boolean,ByVal PageSize As Integer,ByVal ReportCMS As Boolean,ByVal Webmaster As String,ByVal IsHighestWinner As Boolean,ByVal ModerationLevel As Integer,ByVal CurrentSeason As Integer)
	    
		    Dim item As WebSettings = New WebSettings()
		    
				item.Id = Id
				
				item.Name = Name
				
				item.Slogan = Slogan
				
				item.Copyright = Copyright
				
				item.Address = Address
				
				item.SiteURL = SiteURL
				
				item.MailServer = MailServer
				
				item.MailUsername = MailUsername
				
				item.MailPassword = MailPassword
				
				item.EmailVerification = EmailVerification
				
				item.AdminVerification = AdminVerification
				
				item.PageSize = PageSize
				
				item.ReportCMS = ReportCMS
				
				item.Webmaster = Webmaster
				
				item.IsHighestWinner = IsHighestWinner
				
				item.ModerationLevel = ModerationLevel
				
				item.CurrentSeason = CurrentSeason
				
		    item.MarkOld()
		    item.Save(UserName)
	    
	    End Sub
    End Class
End Namespace
